package com.redis1.entity;

import lombok.Data;

import java.io.Serializable;
import java.lang.reflect.Field;

/**
 * 作者: LCG
 * 日期: 2020/7/3 23:23
 * 描述:
 */
@Data
public class TestUU implements Serializable {

    private String userName;

    private String password;

    @Override
    public boolean equals(Object o) {
        Class<?> aClass = o.getClass();
        try {
            Field userName1 = aClass.getDeclaredField("userName");
            userName1.setAccessible(true);
            Object o1 = userName1.get(o);
            return o1.equals(this.userName);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public int hashCode() {
        return this.userName.hashCode();
    }
}
